
//ts用于接口
interface Person {
    age: number;
    name: string;
}
let person1: Person = {
    age: 11,
    name: "aaa"
};
console.log(person1);

//ts用于函数
function add(a: number, b: number): number {
    return a + b;
}
console.log(add(666, 666)); 

//ts用于类
class Animal {
    name: string;
    constructor(name: string) {
        this.name = name;
    }
    eat() {
        console.log(this.name + " is eating");
    }
}
let animal1 = new Animal("dog");
animal1.eat();



// 基本数据类型
let age1: number = 11;
let name1: string = "aaa";

// 布尔类型
let isStudent: boolean = true;

// 数组类型
let ages: number[] = [11, 12, 13];
let names: string[] = ["aaa", "bbb", "ccc"];

// 元组类型
let person: [string, number] = ["aaa", 11];

// 枚举类型
enum Role { Admin, User, Guest };
let userRole: Role = Role.Admin;

// 任意类型
let anyValue: any = "可以是任何类型";
anyValue = 123;

// 空值类型
function printName(name: string): void {
  console.log(name);
}
